#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Create by zhang
# Create on 2022/6/22 17:02
from domain.report.common.period_enum import PeriodEnum
from domain.report.common.period_mapper import PeriodMapper
from infrastructure.util.request_util import get
from infrastructure.common.threadingPool import ThreadPool


"""
财务报表接口：http://listxbrl.sse.com.cn/cash/showmap.do?stock_id=600748.SS&report_year=2022&report_period_id=4000
"""


@ThreadPool(thread_name_prefix="xbrl_")
def cash_spider(stock_code:str, year:int, period:PeriodEnum):
    result = get(url="http://listxbrl.sse.com.cn/cash/showmap.do", data={
        "stock_id": stock_code,
        "year": year,
        "report_period_id": PeriodMapper.get_xbrl_period(period)
    })
    return result